package com.linkwechat.wecom.service.impl;

import com.linkwechat.wecom.domain.WeworkKfLog;
import com.linkwechat.wecom.mapper.WeworkKfLogMapper;
import com.linkwechat.wecom.service.IWeworkKfLogService;
import org.springframework.stereotype.Service;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import org.apache.commons.lang3.StringUtils;

import java.util.List;

/**
 * 企微客服咨询事件日志Service业务层处理
 *
 * @author ruoyi
 * @date 2022-03-02
 */
@Service
public class WeworkKfLogServiceImpl extends ServiceImpl<WeworkKfLogMapper, WeworkKfLog> implements IWeworkKfLogService {

    @Override
    public List<WeworkKfLog> queryList(WeworkKfLog weworkKfLog) {
        LambdaQueryWrapper<WeworkKfLog> lqw = Wrappers.lambdaQuery();
        if (weworkKfLog.getId() != null){
            lqw.eq(WeworkKfLog::getId , weworkKfLog.getId());
        }
        if (StringUtils.isNotBlank(weworkKfLog.getEventType())){
            lqw.eq(WeworkKfLog::getEventType , weworkKfLog.getEventType());
        }
        if (weworkKfLog.getServicerId() != null){
            lqw.eq(WeworkKfLog::getServicerId , weworkKfLog.getServicerId());
        }
        if (weworkKfLog.getCustomerId() != null){
            lqw.eq(WeworkKfLog::getCustomerId , weworkKfLog.getCustomerId());
        }
        if (StringUtils.isNotBlank(weworkKfLog.getOpenKfid())){
            lqw.eq(WeworkKfLog::getOpenKfid , weworkKfLog.getOpenKfid());
        }
        if (weworkKfLog.getSysTime() != null){
            lqw.eq(WeworkKfLog::getSysTime , weworkKfLog.getSysTime());
        }
        if (weworkKfLog.getFailType() != null){
            lqw.eq(WeworkKfLog::getFailType , weworkKfLog.getFailType());
        }
        if (StringUtils.isNotBlank(weworkKfLog.getFailMsgid())){
            lqw.eq(WeworkKfLog::getFailMsgid , weworkKfLog.getFailMsgid());
        }
        if (weworkKfLog.getChangeType() != null){
            lqw.eq(WeworkKfLog::getChangeType , weworkKfLog.getChangeType());
        }
        if (StringUtils.isNotBlank(weworkKfLog.getOldServicerUserid())){
            lqw.eq(WeworkKfLog::getOldServicerUserid , weworkKfLog.getOldServicerUserid());
        }
        if (StringUtils.isNotBlank(weworkKfLog.getNewServicerUserid())){
            lqw.eq(WeworkKfLog::getNewServicerUserid , weworkKfLog.getNewServicerUserid());
        }
        if (weworkKfLog.getServicerStatus() != null){
            lqw.eq(WeworkKfLog::getServicerStatus , weworkKfLog.getServicerStatus());
        }

        return this.list(lqw);
    }
}
